package user

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer(regex('/api/users/\\d+/apps')), producer('/api/users/1/apps'))

    }
    response {
        status 200
        body("""
  {
    "data": [
      {
        "name": "学院论坛",
        "link": "/../bbs/login",
        "icon": "tags"
      },
      {
        "name": "成长日志",
        "link": "/practise-diary/index.html",
        "icon": "star"
      },
      {
        "name": "训练营",
        "link": "/program-center/student/index.html",
        "icon": "folder"
      }
    ]
  }
 """)
        bodyMatchers {
            jsonPath('$.data.[*].name', byRegex(onlyAlphaUnicode()))
            jsonPath('$.data.[*].icon', byRegex(onlyAlphaUnicode()))
        }
        headers {
            header('Content-Type': 'application/json;charset=UTF-8')
        }
    }
}